var express = require('express');
var router = express.Router();


//根据名字找爱好
router.get('/showlike',function(req,res,next){
    res.render('likeview/findname',{title : 'Show By Username'});});
  



//显示爱好页面
router.get('/likelist',function(req,res,next){
    var db=req.db;
    var collection = db.get('userinfo');
    var username=req.query.username;
    collection.find({'username':username},{},function(e,docs){
        res.render('likeview/showlike',{
          'showlike':docs
        })
    })
  })



//   //添加爱好的界面
// router.get('/newlike',function(req,res,next){
//     res.render('likeview/newlike',{title : 'Add New Like'});
// })

// //上传添加的爱好并显示
// router.post('/addlike',function(req,res,next){
  
//     var db=req.db;
//     var username=req.body.username;
//     var like=req.body.like;
    
//     var collection = db.get('userinfo');
//     length=collection.like.length;
//     collection.update(
//      {"username" :username},{$set:{'like.':{}}
     

   
//     ),function(err,doc){
//       if (err) {
//        res.send("There was a problem adding the information to the database.");
//       }
//       else{
       
//        res.redirect("userview//userlist");
//       }
//     }
//    })


module.exports = router;